package com.tongcao.cn.service;

import com.aliyun.oss.model.Bucket;
import com.aliyun.oss.model.BucketInfo;
import com.aliyun.oss.model.GenericResult;
import com.aliyun.oss.model.ObjectListing;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.InputStream;

/**
 * @Author:tongcao
 * @Date:2019/1/5 11:15
 * Description:
 */
public interface IOssService {

    /**
     * 创建bucket
     *
     * @param bucketName
     */
    Bucket createBucket(String bucketName);


    BucketInfo getBucketInfo(String bucketName);

    /**
     * 上传文件
     *  @param bucketName
     * @param fileKey
     * @param file
     */
    GenericResult uploadFile(String bucketName, String fileKey, File file);

    /**
     * 上传文件
     * @param fileKey
     * @param file
     */
    GenericResult uploadFile(String fileKey, File file);


    /**
     * 上传文件
     * @param fileKey
     * @param inputStream
     */
    GenericResult uploadFile(String fileKey, InputStream inputStream);


    String uploadFile2OSS(InputStream inputStream, String fileName);


    String uploadImg2Oss(MultipartFile file);
    /**
     * 上传文件
     * @param fileKey
     * @param inputStream
     */
    GenericResult uploadFileIg(String fileKey, InputStream inputStream);


    ObjectListing listFile(String bucketName);

    /**
     * 删除文件
     *
     * @param bucketName
     * @param fileKey
     */
    void deleteFile(String bucketName, String fileKey);
}
